package com.jay.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class LoginActivity extends Activity {

	private Toast mToast;
	private TextView newUserTextView;
	private TextView cannotLoginTextView;
	private Button loginButton;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(
				WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
				WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);
		resourceInit();
		mToast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
	}

	private class LoginOnClickListener implements View.OnClickListener {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch (v.getId()) {
			case R.id.new_user:
				Intent intent1 = new Intent(LoginActivity.this,
						FillinNumberActivity.class);
				startActivity(intent1);
				break;
			case R.id.cannot_login:
				showTip("无法登陆");
				break;
			case R.id.login_button:
				Intent intent2 = new Intent(LoginActivity.this,
						MainActivity.class);
				startActivity(intent2);
				break;

			default:
				break;
			}
		}
	}

	void resourceInit() {
		newUserTextView = (TextView) findViewById(R.id.new_user);
		cannotLoginTextView = (TextView) findViewById(R.id.cannot_login);
		loginButton = (Button) findViewById(R.id.login_button);
		newUserTextView.setOnClickListener(new LoginOnClickListener());
		cannotLoginTextView.setOnClickListener(new LoginOnClickListener());
		loginButton.setOnClickListener(new LoginOnClickListener());
	}

	private void showTip(final String str) {
		runOnUiThread(new Runnable() {
			@Override
			public void run() {
				mToast.setText(str);
				mToast.show();
			}
		});
	}

}
